﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DataAccessLayer;

namespace BusinessComponents.Implementation
{
    class GuestBLL
    {
        private GuestRepository repo = new GuestRepository();

        public void addGuest(Guest g)
        {
            repo.Add(g);
            repo.Commit();
        }

        public Guest FindById(int id)
        {
            return repo.FindById(id);
        }

        public IEnumerable<Guest> FindAllGuest()
        {
          return  repo.GetAll();
        }

        public IEnumerable<Guest> FindGuestByName(String name)
        {
            return repo.GetAll().Where(o => o.FirstName == name || o.LastName == name);
        }

        public Guest FindByEmail(string email)
        {
            return repo.GetAll().SingleOrDefault(o => !string.IsNullOrEmpty(o.Email) && o.Email.Equals(email));
        }
    }
}
